﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="A5Site.WebUserControl1" %>
<script runat="server">
    protected int currentColorIndex;
    protected String[] colors = {"Red", "Blue", "Green", "Yellow"};
    public System.Drawing.Color currentColor { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            currentColorIndex = 
                Int16.Parse(ViewState["currentColorIndex"].ToString());
        }
        else
        {
            currentColorIndex = 0;
            DisplayColor();
        }
    }

    protected System.Drawing.Color getCurrentColor()
    {
        return System.Drawing.Color.FromName(colors[currentColorIndex]);
    }
    
    protected void DisplayColor()
    {
        textColor.Text = colors[currentColorIndex];
        System.Drawing.Color color = new System.Drawing.Color();
        color = System.Drawing.Color.FromName(colors[currentColorIndex]);
        textColor.BorderColor = color;
        btnLogin.BackColor = color;
        btnAdmin.BackColor = color;
        btnUser.BackColor = color;
        ViewState["currentColorIndex"] = currentColorIndex.ToString();
        
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Response.Redirect("Login.aspx");
    }
    
    protected void btnAdmin_Click(object sender, EventArgs e)
    {
        if (Session["myuser"] == null)
            Response.Redirect("Login.aspx");
        else
            Response.Redirect("Admin.aspx");       
    }

    protected void btnUser_Click(object sender, EventArgs e)
    {
        if (Session["myuser"] == null)
            Response.Redirect("Login.aspx");
        else
            Response.Redirect("User.aspx");
    }
    
    protected void buttonUp_Click(object sender, EventArgs e)
    {
        if(currentColorIndex == 0)
        {
            currentColorIndex = colors.Length - 1;
        }
        else
        {
            currentColorIndex -= 1;
        }
        DisplayColor();
    }

    protected void buttonDown_Click(object sender, EventArgs e)
    {
        if(currentColorIndex == (colors.Length - 1))
        {
            currentColorIndex = 0;
        }    
        else
        {
            currentColorIndex += 1;
        }
        DisplayColor();
    }
</script>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Button Color<br />
<asp:TextBox ID="textColor" runat="server" 
    ReadOnly="True" />
<asp:Button Font-Bold="True" ID="buttonUp" runat="server" 
    Text="^" OnClick="buttonUp_Click" />
<asp:Button Font-Bold="True" ID="buttonDown" runat="server" 
    Text="v" OnClick="buttonDown_Click" />
<asp:Button ID="btnLogin" runat="server" Text="Login" 
    onclick="btnLogin_Click" />&nbsp&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnUser" runat="server" style="margin-left: 0px" 
    Text="Manage Schedule" onclick="btnUser_Click" />&nbsp&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnAdmin" runat="server" Text="Manage Users" 
    onclick="btnAdmin_Click" />&nbsp&nbsp;&nbsp;&nbsp;


